package net.zjitc.datasource.book;

import java.util.Objects;

/**
 * @Author Administrator
 * @Date 2020/5/26 14:01
 * domain层
 * 标准类JavaBean
 * 与数据库表一一对应
 * 包含哪些内容：
 * 1、成员变量（私有的）（属性与表中字段一一对应）
 * 2、成员方法：setter/getter方法
 * 3、构造方法（无参、有参）
 * 4、可能还需要重写：
 * toString()
 * equals()
 * 自动生成方法： Alt+Insert
 **/
public class Book {
    private int id;
    private String name;
    private String press;
    private String author;
    private double price;

    public Book() {
    }

    public Book(String name, String press, String author, double price) {
        this.name = name;
        this.press = press;
        this.author = author;
        this.price = price;
    }

    public Book(int id, String name, String press, String author, double price) {
        this.id = id;
        this.name = name;
        this.press = press;
        this.author = author;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", press='" + press + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Book book = (Book) o;
        return id == book.id &&
                Double.compare(book.price, price) == 0 &&
                Objects.equals(name, book.name) &&
                Objects.equals(press, book.press) &&
                Objects.equals(author, book.author);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, press, author, price);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPress() {
        return press;
    }

    public void setPress(String press) {
        this.press = press;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }


}
